import paramiko


class DevicesManager:
    def __init__(self, frida_manager):
        pass


class AndroidDevicesManager(DevicesManager):
    def __init__(self, frida_manager):
        pass


class IosDevicesManager(DevicesManager):
    def __init__(self, frida_manager):
        pass
        # self.hostname = '127.0.0.1'
        # self.username = 'root'
        # self.password = password
        # self.ssh = paramiko.SSHClient()

    def __del__(self):
        self.ssh.close()

    def connect(self):
        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        try:
            self.ssh.connect(hostname=self.hostname, username=self.username, password=self.password, allow_agent=True,
                             timeout=5, port=2222)
        except Exception as e:
            print(e)

    def exec_cmd(self, cmd):
        try:
            stdin, stdout, stderr = self.ssh.exec_command(cmd)
            exec_result = stdout.readlines()
            ret = []
            for item in exec_result:
                ret.append(item.replace('\n', ''))
            return ret
        except Exception as e:
            print(e)
